#ifndef __MARS_SCENEGRAPH_SCENEMGR_H__
#define __MARS_SCENEGRAPH_SCENEMGR_H__

#include "MarsObject.h"
#include "MarsLight.h"

namespace GObject
{
class GameObject;
class Camera;
} // end of namespace GObject

namespace SceneGraph
{

class SceneNode;

class SceneMgr : public Object
{
public:
	virtual							~SceneMgr();

	bool							Initialize();
	void							Shutdown();

	static SceneMgr&				Instance();
	static void						Destroy();

	GameObject*						CreateGameObject();
	GameObject*						CreateGameObject( const std::string& strName );
	void							DestroyGameObject( const std::string& strName );
	void							DestroyGameObject( GameObject* pGameObject );
	GameObject*						FindGameObject( const std::string& strName );

	virtual void					Update( float dt );
	virtual void					Render( const Camera& camera );

protected:
	virtual void					GetLights( LightsList& list );
	void							DestroyAllSceneNodes();

private:
									SceneMgr();
									SceneMgr( const SceneMgr& );
	SceneMgr&						operator = ( const SceneMgr& );

	static SceneMgr*				ms_pSceneMgr;

private:
	typedef std::map< std::string, SceneNode* >		SceneNodeMap;
	typedef SceneNodeMap::iterator			SceneNodeMapItr;
	typedef SceneNodeMap::const_iterator	SceneNodeMapConstItr;

	SceneNodeMap					m_mapSceneNodes;
	SceneNode*						m_pRootNode;
};

inline SceneMgr& SceneMgr::Instance()
{
	if ( !ms_pSceneMgr )
	{
		ms_pSceneMgr = new SceneMgr();
	}

	return ( *ms_pSceneMgr );
}

} // end of namespace SceneGraph

#endif // end of #ifndef __MARS_SCENEGRAPH_SCENEMGR_H__